<script>
export default {
	data(){
		return {
			staTime:'',//进入时间
			levTime:'',//离开时间
		};
	},
	onLaunch() {},
	onShow: function() {
		console.log('App Show');
		uni.$emit('app-show');
		this.staTime=new Date().getTime()
	  uni.setStorageSync('vedioData','')
		//存储时
		uni.setStorageSync('joinTime',this.staTime)
	},
	onHide: function() {
		console.log('App Hide');
		uni.$emit('app-hide');
		// 在线时长统计
		this.levTime=new Date().getTime()
		const time=parseInt((this.levTime - this.staTime) / 1000)?parseInt((this.levTime - this.staTime) / 1000):1;
		const onlineStart=this.$u.timeFormat(this.staTime, 'yyyy-mm-dd hh:MM:ss')
		const pageData={
			duration:time,
			onlineStart,
			userStudies:[],
			userType:4
		}
		if(uni.getStorageSync('vedioData')) return;
		const vuex_user=this.vuex_user;
		uni.request({
			url:this.host+'/app/home/reportUserOnline',
			method:"POST",
			data:pageData,
			header: {
				"token": vuex_user && vuex_user.token || "",
				"platform":"app"
			},
			success(res) {
				console.log(res,'在线接口成功')
			},
			fail(err) {
				if (err.errMsg.indexOf("timeout") !== -1) {
					uni.showToast({
						title: '网络异常！'
					})
				}
				console.log('获取数据异常！', err);
				reject(err)
			},
		})
	},

};
</script>

<style lang="scss">

/* #ifndef APP-NVUE */
@import 'uview-ui/index.scss';
@import 'style/paper-item.scss';

/*每个页面公共css */
uni-page-body,
html,
body {
	height: 100%;
	width: 100%;
}
button:after {
	border: none;
}
.status_bar {
	height: var(--status-bar-height);
	width: 100%;
}
.padding-btm {
	padding-bottom: var(--window-bottom);
}
.padding-top {
	padding-top: var(--window-top);
}
.pd-30 {
	padding-bottom: 30upx;
}
::-webkit-scrollbar {
	display: none;
	width: 0 !important;
	height: 0 !important;
	-webkit-appearance: none;
	background: transparent;
}
.switch {
	position: absolute;
	left: 0;
	top: 0;
	bottom: 0;
	right: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	margin: 0 60upx;
	font-size: 30upx;
	font-weight: 500;
	color: #ffffff;
	text {
		padding: 0 20upx;
		opacity: 0.5;
		transition: font-size 0.2s;
	}
	.active {
		font-size: 36upx;
		opacity: 1;
		font-weight: 500;
	}
}
//自定义导航 确定按钮
.u-navbar .confirm {
	font-size: 30upx;
	font-weight: 400;
	color: #ffffff;
	padding-right: 30upx;
}
//文字省略
.text-ellipsis {
	text-overflow: ellipsis;
	white-space: nowrap;
	overflow: hidden;
	display: block;
}
//collapse默认样式
/deep/ .u-collapse-item {
	.u-collapse-head {
		height: 110upx;
		margin: 0 30upx;
		padding: 0;
		flex: 1;
		text-overflow: ellipsis;
		white-space: nowrap;
		overflow: hidden;
	}
	.u-collapse-head {
		font-size: 32upx;
		font-weight: 400;
		color: #363940;
	}
	.u-collapse-body {
		margin-left: 60upx;
		line-height: 110upx;
	}
}
/deep/ .u-navbar {
	background: linear-gradient(-90deg, #40405c 0%, #69698b 100%) !important;
	font-size: 34upx;
	font-weight: 500;
}
.flex--c--c {
	display: flex;
	align-items: center;
	justify-content: center;
}
/*  #endif  */
</style>
